// 笔试强训day26：不相邻取数

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n = 0, tmp = 0; cin >> n;
    vector<int> dp(n + 2, 0);
    for(int i = 2; i <= n + 1; i++)
    {
        cin >> tmp;
        dp[i] = max(dp[i - 1], dp[i - 2] + tmp);
    }

    cout << dp[n + 1] << endl;
}